import { roleList } from "@/request/api"

// 封装一个state接口
interface roleState {
    rolelist: Array<object>
}


const state = {
    rolelist: []
}

const getters = {
    getRoleList(state: roleState) {
        return state.rolelist
    }
}

const mutations = {
    REQ_ROLELIST(state: roleState, payload: any) {
        state.rolelist = payload
    }
}

const actions = {
    RoleListActions(context: any) {
        roleList()
            .then((res: any) => {
                console.log(res, '角色列表');
                if (res.code == 200) {
                    context.commit('REQ_ROLELIST', res.list)
                }
            })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}